﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<script src="js/jquery.min.js"></script>
<title>打印画</title>
</head>
<body>
<!--<form method="post" action="http://localhost:8080/web/pic" enctype="multipart/form-data">  
    <input type="file" name="pic">  
    <input type="submit" value="submit">  
 </form> -->

 <form id="addPhotoFrom" method="post"  enctype="multipart/form-data">  
    <input id="picUrl1" name="photo" type="file" class="" value=""  accept="image/*" multiple>
  </form> 
  <button id="s">提交</button>
  
  <div id="picGallery">
  </div>

  <script>

    $('#s').click(function() {
        ajaxFileUpload();
    });
    function ajaxFileUpload() {  
  
    var formData = new FormData();//表单id  
    var pic = document.getElementById("picUrl1").files[0];
    formData.append("photo", pic);
  
    $.ajax({  
        //url : "http://localhost:8080/web/uploadPhoto",  
        url : "/web/uploadPhoto",
        type : "POST",  
        data : formData,  
        async : false,  
        cache : false,  
        contentType : false,  
        processData : false,  
        success : function(data) {  
            console.log('success');
            console.log(data);
            $("#picGallery").empty();
            if(data.meta.success) {
            	var arr = data.data;
            	for(var i = 0; i < arr.length; i++) {
            		var img = "<div><img src='/web" + arr[i] + "'/></div>"
            		console.log(img);
            		$("#picGallery").append(img);		
            	}
            }
        },  
        error : function(e) {  
            console.log('error');  
        }  
    });  
  
}  
  </script>
</body>
</html>